//
//  VoiceReadDetailReplyHeaderView.m
//  ShowYork
//
//  Created by hxh on 2021/4/20.
//  Copyright © 2021 hxh. All rights reserved.
//

#import "VoiceReadDetailReplyHeaderView.h"

@interface VoiceReadDetailReplyHeaderView ()
@property (nonatomic,strong)UIView *line;
@property (nonatomic,strong)UILabel *titleLb;
@property (nonatomic,strong)UILabel *countLb;
@property (nonatomic,strong)UILabel *replyLb;
@property (nonatomic,strong)UIButton *replyBtn;
@end

@implementation VoiceReadDetailReplyHeaderView
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}
- (void)setUI{
    self.frame = CGRectMake(0, 0, kScreenW, 64);
    
    self.line = [[UIView alloc]init];
    self.line.backgroundColor = RGBA(245, 75, 100, 1);
    [self addSubview:self.line];
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(16);
        make.size.mas_equalTo(CGSizeMake(6, 20));
        make.bottom.equalTo(self).offset(-24);
    }];
    self.titleLb = [[UILabel alloc]init];
    self.titleLb.text = @"评论";
    self.titleLb.textColor = C51;
    self.titleLb.font = [UIFont boldSystemFontOfSize:20];
    [self addSubview:self.titleLb];
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.line.mas_right).offset(10);
        make.centerY.equalTo(self.line);
    }];
    self.countLb = [[UILabel alloc]init];
    self.countLb.text = @"(10)";
    self.countLb.textColor = C51;
    self.countLb.font = font(12);
    [self addSubview:self.countLb];
    [self.countLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.line);
        make.left.equalTo(self.titleLb.mas_right).offset(2);
    }];
    self.replyLb = [[UILabel alloc]init];
    self.replyLb.text = @"写评论";
    self.replyLb.textColor = C51;
    self.replyLb.font = font(12);
    [self addSubview:self.replyLb];
    [self.replyLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.line);
        make.right.equalTo(self).offset(-16);
    }];
    self.replyBtn = [[UIButton alloc]init];
    [self.replyBtn addTarget:self action:@selector(replyMethod) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.replyBtn];
    [self.replyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self);
        make.centerY.equalTo(self.line);
        make.size.mas_equalTo(CGSizeMake(100, 40));
    }];
}

- (void)replyMethod{
    if (self.delegate && [self.delegate respondsToSelector:@selector(showReplyView)]) {
        [self.delegate showReplyView];
    }
}
- (void)setMaxCount:(NSInteger)maxCount{
    NSString *title = @"";
    if (maxCount >= 10000) {
        if (maxCount % 1000 == 0) {
            maxCount += 1;
        }
        title = [NSString stringWithFormat:@"(%@w)",[RPAppManager notRounding:maxCount/10000.0f afterPoint:1]];
    }else{
        if (maxCount != 0) {
            title = [NSString stringWithFormat:@"(%lu)",maxCount];
        }
    }
    self.countLb.text = title;
}

@end
